#include "manualconfirmationdlg.h"
#include "ui_manualconfirmationdlg.h"

ManualConfirmationDlg::ManualConfirmationDlg(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::ManualConfirmationDlg)
{
    ui->setupUi(this);

    buzzer_ok = false;
    motor_ok = false;
    led_ok = false;

    ui->label_tip->setFont(QFont("方正舒体", 16));
    ui->label_buzzer->setFont(QFont("方正舒体", 16));
    ui->label_motor->setFont(QFont("方正舒体", 16));
    ui->label_led->setFont(QFont("方正舒体", 16));
    ui->checkBox_buzzer->setFont(QFont("方正舒体", 16));
    ui->checkBox_motor->setFont(QFont("方正舒体", 16));
    ui->checkBox_led->setFont(QFont("方正舒体", 16));
    ui->checkBox_all->setFont(QFont("方正舒体", 16));
    ui->pushButton_ok->setFont(QFont("方正舒体", 16));
}

ManualConfirmationDlg::~ManualConfirmationDlg()
{
    buzzer_ok = ui->checkBox_buzzer->isChecked();
    motor_ok = ui->checkBox_motor->isChecked();
    led_ok = ui->checkBox_led->isChecked();

    delete ui;
}

bool ManualConfirmationDlg::GetBuzzer()
{
    return buzzer_ok;
}

bool ManualConfirmationDlg::GetMotor()
{
    return motor_ok;
}

bool ManualConfirmationDlg::GetLed()
{
    return led_ok;
}

void ManualConfirmationDlg::on_pushButton_ok_clicked()
{
    buzzer_ok = ui->checkBox_buzzer->isChecked();
    motor_ok = ui->checkBox_motor->isChecked();
    led_ok = ui->checkBox_led->isChecked();
    this->close();
}

void ManualConfirmationDlg::on_checkBox_all_stateChanged(int state)
{
    if (state == Qt::Unchecked) {
        ui->checkBox_buzzer->setCheckState(Qt::Unchecked);
        ui->checkBox_motor->setCheckState(Qt::Unchecked);
        ui->checkBox_led->setCheckState(Qt::Unchecked);
    } else {
        ui->checkBox_buzzer->setCheckState(Qt::Checked);
        ui->checkBox_motor->setCheckState(Qt::Checked);
        ui->checkBox_led->setCheckState(Qt::Checked);
    }
}
